package com.yiji.fintech.musfinance.center.sign.order.facade;

import com.acooly.core.common.exception.OrderCheckException;
import com.acooly.core.utils.Strings;
import com.acooly.core.utils.ToString;
import com.yiji.fintech.musfinance.base.enums.*;
import com.yiji.fintech.musfinance.center.base.order.OrderFacade;
import lombok.Data;

import javax.validation.constraints.NotNull;

/**
 * Created by ouwen@yiji.com} on 2017/4/13.
 * 签约 facade 接口参数
 */
@Data
public class SignFacadeOrder extends OrderFacade {
    /** 账户名 对私：用户姓名/对公：公司名称*/
    @NotNull
    private String accountName;
    /** 证件号码 对私：身份证号/对公：营业执照号*/
    @NotNull
    private String certNo;
    /**银行账号*/
    @NotNull
    private String accountNo;
    /**电话号码*/
    @NotNull
    private String phoneNo;
    /**银行编码*/
    @NotNull
    private String bankId;
    /** 验证要素类型 */
    @NotNull
    private ElementTypeEnum elementType;
    /**省份 -对公必传*/
    protected String province;
    /**城市 -对公必传*/
    protected String city;
    /**证件类型*/
    private CertTypeEnum certType = CertTypeEnum.IDENTITY_CARD;
    /**卡类型*/
    private CardTypeEnum cardType = CardTypeEnum.DEBIT;
    /** 付款-对公:CORPORATE / 对私:PERSONAL默认对私*/
    private PersonalCorporateTypeEnum accountType = PersonalCorporateTypeEnum.PERSONAL;
    /** 币种*/
    private CurrencyEnum currency;

    @Override
    public void check() {
        if(PersonalCorporateTypeEnum.CORPORATE == accountType &&
                (Strings.isEmpty(province)||Strings.isEmpty(city))){//对公卡,省/市必填
            throw new OrderCheckException("对公卡省/市必填", "请求参数不完整:");
        }
    }

    @Override
    public String toString() {
        return ToString.toString(this);
    }
}
